<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">

    <button v-for="item in btns" @click="handleClick(item)">{{item.text}}</button>
    <component :is="getCurrent"></component>
  </div>
  <script>

    Vue.component('costom-position', {
      // props: ['btntext'],
      template: `
      <div>职位列表</div>
      `
    })

    Vue.component('costom-search', {
      // props: ['btntext'],
      template: `
      <div>搜索</div>
      `
    })

    Vue.component('costom-profile', {
      // props: ['btntext'],
      template: `
      <div>我的</div>
      `
    })

    var vm = new Vue({
      el: "#app",
      data: {
        currentTag:'position',
        btns: [{text:'职位',id:'position'}, {text:'搜索',id:'search'}, {text:'我的',id:'profile'}]
      },
      computed:{
        getCurrent(){
          return 'costom-'+ this.currentTag;
        }
      },
      methods:{
        handleClick(item){
          this.currentTag=item.id
        }
      }
    })

  </script>

</body>

</html>